package leetcodecompetition.D339;

import org.junit.jupiter.api.Test;

public class T6362 {
    public int findTheLongestBalancedSubstring(String s) {
        int len = s.length();
        int a = 0;
        int b = 0;
        int re = 0;
        int i = 0;
        while (i<len) {
            while (i < len && s.charAt(i) == '0') {
                i++;
                a++;
            }
            while (i < len && s.charAt(i) == '1') {
                i++;
                b++;
            }
            re = Math.max(re, Math.min(a, b));
            a = 0;
            b = 0;
        }
        return re*2;
    }
    @Test
    public void test() {

        System.out.println(findTheLongestBalancedSubstring("01000111"));
    }
}
